Fix use of describe-prefix-bindings in which-key-show-standard-help
authorJustin Burkett <justin@burkett.cc>
Wed, 14 Nov 2018 14:32:27 +0000 (09:32 -0500)
committerJustin Burkett <justin@burkett.cc>
Wed, 14 Nov 2018 14:32:27 +0000 (09:32 -0500)
Use describe-prefix-bindings directly if we do not enter through
which-key-C-h-dispatch.

Fixes #198

which-key.el

index c62924da823ddf597b7671af22b4e63d1789b32a..d901a31173ae16109f5b83d6facf8ba97aca36d1 100644 (file)
@@ -2193,13 +2193,18 @@ used are reapplied to the new key sequence."
   "Call the command in `which-key--prefix-help-cmd-backup'.
 Usually this is `describe-prefix-bindings'."
   (interactive)
-  (let ((which-key-inhibit t))
+  (let ((which-key-inhibit t)
+        (popup-showing (which-key--popup-showing-p)))
     (which-key--hide-popup-ignore-command)
-    (cond ((eq which-key--prefix-help-cmd-backup
-               'describe-prefix-bindings)
-           ;; This is essentially what `describe-prefix-bindings' does
-           (describe-bindings
-            (kbd (which-key--current-key-string))))
+    (cond ((and (eq which-key--prefix-help-cmd-backup
+                    'describe-prefix-bindings)
+                ;; If the popup is not showing, we call
+                ;; `describe-prefix-bindings' directly.
+                popup-showing)
+           ;; This is essentially what `describe-prefix-bindings' does. We can't
+           ;; use this function directly, because the prefix will not be correct
+           ;; when we enter using `which-key-C-h-dispatch'.
+           (describe-bindings (kbd (which-key--current-key-string))))
           ((functionp which-key--prefix-help-cmd-backup)
            (funcall which-key--prefix-help-cmd-backup)))))